﻿@using RGA.Helpers
@using RGA.Models
@model RGA.Models.Route

@{
    ViewBag.Title = "Wygenerowana trasa";
}

<h2>Trasa</h2>


@if (User.IsInRole("Kierowca"))
{
    @Html.ActionLink("Wersja do druku", "RoutePrintVersion", "Routes", new {Model.Id}, new {@class = "btn btn-default"})

    if (Model.State == RouteState.New)
    {
        @Html.ActionLink("Rozpocznij trasę!", "StartRoute", "Routes", new {Model.Id}, new {@class = "btn btn-primary btn-lg"})
    }

    if (Model.State == RouteState.InProgress)
    {
        @Html.ActionLink("Zakończ trasę!", "EndRoute", "Routes", new {Model.Id}, new {@class = "btn btn-primary btn-lg"})
    }

    if (Model.State == RouteState.Completed)
    {
        @Html.Encode(" Trasa została zakończona.")
    }
}


@if (User.IsInRole("Pracownik"))
{
    @*Html.ActionLink("Wersja do druku", "RoutePrintVersion", "Routes", new { Model.Id }, new { @class = "btn btn-default" })
    @Html.Encode(" | ")*@
    @Html.ActionLink("Edytuj trasę", "Edit", new {id = Model.Id}, new {@class = "btn btn-default"})
    @Html.Encode(" | ")
    @Html.ActionLink("Usuń trasę", "Delete", new {id = Model.Id}, new {@class = "btn btn-default"})
}

<div>
    <h4>Szczegóły trasy</h4>

    <hr />
    <dl class="dl-horizontal">
        

        <dt>
            @Html.DisplayNameFor(model => model.Worker)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Worker.UserName)
        </dd>

        @if (!User.IsInRole("Kierowca"))
        {
            <dt>
                @Html.DisplayNameFor(model => model.Driver)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.Driver.UserName)
            </dd>
        }



        <dt>
            @Html.DisplayNameFor(model => model.DynamicMapHtml)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.DynamicMapHtml)
        </dd>
        
        

        <dt>
            @Html.DisplayNameFor(model => model.StartAddress)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.StartAddress)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Shipments)
        </dt>
        <dd>
            <ul>
                @foreach (Shipment shipment in Model.Shipments)
                {
                    <li>Nr: @shipment.Number | Adres: @shipment.DestinationAddress</li>
                }
            </ul>
        </dd>
        


        <dt>
            @Html.DisplayNameFor(model => model.EndAddress)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.EndAddress)
        </dd>
        
        @if (!User.IsInRole("Kierowca"))
        {
            <dt>
                @Html.DisplayNameFor(model => model.Image)
            </dt>

            <dd>
                <img src="@string.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(Model.Image))"/>
            </dd>
        }
        <dt>
            @Html.DisplayNameFor(model => model.Description)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Description)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Summary)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Summary)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.StartDateTime)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.StartDateTime)
        </dd>



        <dt>
            @Html.DisplayNameFor(model => model.Duaration)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Duaration)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Distance)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Distance)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.State)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.State)
        </dd>
        
        <dt>
            @Html.DisplayNameFor(model => model.AllowTollRoads)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.AllowTollRoads)
        </dd>

        @if (!User.IsInRole("Kierowca"))
        {
            <dt>
                @Html.DisplayNameFor(model => model.DistanceMatrixProvider)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.DistanceMatrixProvider)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.RouteOptimizationAlgorithm)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.RouteOptimizationAlgorithm)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.RouteOptimizationProvider)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.RouteOptimizationProvider)
            </dd>

            <dt>
                @Html.DisplayNameFor(model => model.RouteOptimizationType)
            </dt>

            <dd>
                @Html.DisplayFor(model => model.RouteOptimizationType)
            </dd>
        }
        
        <dt>
            Szczegółowy opis trasy
        </dt>

        <dd>
            <ul>
                @foreach (Segment segment in Model.Segments)
                {
                    <li>Odcinek z @segment.StartAddress do @segment.EndAddress
                        <br/>
                        (długość: @segment.Distance metrów, czas: @segment.Duaration)
                        <br/><br />
                        <ol>
                            @foreach (Step step in segment.Steps)
                            {
                                <li>
                                    Krok z @step.StartLocation do @step.EndLocation
                                    (długość: @step.Distance metrów, czas: @step.Duaration)
                                    <br />
                                    @Html.DisplayFor(s => step.HtmlInstructions)
                                    <br /><br />
                                </li>
                            }
                        </ol>
                        <hr />
                    </li>
                }
            </ul>

        </dd>
        

    </dl>
</div>

<p>
 
   
    @if (User.IsInRole("Admin"))
    {
        @Html.ActionLink("Wróc do listy", "Index", "Routes", new {}, new {@class = "btn btn-default"})
    }

</p>